﻿#region Using Statements
using System;
using DirectZZT.Shared.World.Objects;
using DirectZZT.Shared.Core;
using DirectZZT.Shared.World;
#endregion

namespace DirectZZT.BoardObjects
{
    /// <summary>
    /// Represents the ricochect ("Ricochet") board object.
    /// </summary>
    [Export("Ricochet")]
    [BoardObject(Identifier = "Ricochet", Classification = BoardObjectClassification.Terrain, AllowBecome = false)]
    public sealed class RicochetBoardObject : BoardObject
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the RicochetBoardObject class.
        /// </summary>
        public RicochetBoardObject()
        {
            this.Texture = "Textures/PlayfieldObjects/Ricochet";
            this.Enabled = true;
            this.Visible = true;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Only in DirectZZT feature.
        /// </summary>
        /// <param name="featureSet"></param>
        /// <returns></returns>
        protected override bool CanAttachScript(FeatureSet featureSet)
        {
            return featureSet == FeatureSet.DirectZZT;
        }

        /// <summary>
        /// Handles collision of objects with this one.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override CollisionResolveArgs OnCollide(CollisionArgs args)
        {
            IProjectileBoardObject projectile = args.Object as IProjectileBoardObject;
            if (projectile != null)
            {
                projectile.TravelDirection = projectile.TravelDirection.Invert();
            }

            return base.OnCollide(args);
        }

        #endregion
    }
}
